package com.woniu.rabbit.topic_model.producer;

import com.woniu.rabbit.topic_model.topic_queue_conf.TopicExchangeAndQueueConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/topic")
@Slf4j
@Api("主题模型")
public class TopicProducerController {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    @GetMapping("/producer")
    @ApiOperation("主题模型生产者")
    public ResponseEntity topicProducer(String msg){
        log.info("主题模型生产者发送的消息为：{}",msg);
        rabbitTemplate.convertAndSend(TopicExchangeAndQueueConfig.EXCHANGE_NAME,"china.N",msg+"china.N");
        rabbitTemplate.convertAndSend(TopicExchangeAndQueueConfig.EXCHANGE_NAME,"china.NN",msg+"china.NN");
        rabbitTemplate.convertAndSend(TopicExchangeAndQueueConfig.EXCHANGE_NAME,"aa.news",msg+"aa.news");
        rabbitTemplate.convertAndSend(TopicExchangeAndQueueConfig.EXCHANGE_NAME,"NiceCounty.news",msg+"NiceCounty.news");
        rabbitTemplate.convertAndSend(TopicExchangeAndQueueConfig.EXCHANGE_NAME,"ZZZ",msg+"ZZZ");
        return ResponseEntity.ok("消息发送成功");
    }
}
